var $editForm = $("#editForm");
$editForm.delegate('.js-submit', 'click', function(){
    $editForm.data('bootstrapValidator').validate();
    if(!$editForm.data('bootstrapValidator').isValid()){
        return false;
    }
    if (!confirm("确定要提交修改？")) {
        return false;
    }

    var url = BASE_PATH + '/bg/manager/save'
    var param = serializeArrayToJson($editForm.serializeArray());
    $.post(url, param, function(resp) {
        if (resp.code != 0) {
            doAlert(resp.message || '操作失败！');
            return false;
        }
        doAlert('修改成功！', 1500, 'success', function() {
            window.location.href = "./list"
        })
    })
})

function initValidator(){
    $editForm.bootstrapValidator({
        container : 'tooltip',
        excluded : [ ":disabled" ],
        feedbackIcons : {
            valid : 'glyphicon glyphicon-ok',
            invalid : 'glyphicon glyphicon-remove',
            validating : 'glyphicon glyphicon-refresh'
        }
    });
}

$(document).ready(function(){
    initValidator();
})